<?php
# 基本函数，常用类

class basic{
	# 创建新token
	# return token
	static function newToken(){
		return md5(time());
	}
	# 创建新Guid
	# return Guid 10000008-1004-2004-3004-100000000012 大写
	static function newGuid(){
	   #if (function_exists('com_create_guid')){
	   #    return com_create_guid();
	   #}else{
       mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
       $charid = strtoupper(md5(uniqid(rand(), true)));
       $hyphen = chr(45);// "-"
       $uuid = // chr(123). "{"
               substr($charid, 0, 8).$hyphen
               .substr($charid, 8, 4).$hyphen
               .substr($charid,12, 4).$hyphen
               .substr($charid,16, 4).$hyphen
               .substr($charid,20,12);// .chr(125)"}"
       return strtoupper($uuid);
	   #}
	}
	# 获取文件的后缀 
	# return 小写后缀
	static function getExt($filename){
	    $ext= explode('.' , $filename);  //用点号分隔文件名到数组
	    $ext = array_reverse($ext);  //把上面数组倒序
	    return strtolower($ext[0]); //返回倒序数组的第一个值
	}
}

?>